package com.jucai.pppeiyouclient.view.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jucai.pppeiyouclient.MainActivity;
import com.jucai.pppeiyouclient.R;
import com.jucai.pppeiyouclient.base.BaseActivity;
import com.jucai.pppeiyouclient.base.QuickFragmentAdapter;
import com.jucai.pppeiyouclient.utils.ActivityCollector;
import com.jucai.pppeiyouclient.utils.ScreenUtil;
import com.jucai.pppeiyouclient.view.fragment.NegParAgreedFragment;
import com.jucai.pppeiyouclient.view.fragment.NegParToAgreeFragment;

import java.util.ArrayList;
import java.util.List;

public class NegativeEnlistUserActivity extends BaseActivity {
    private static final String TAG = "NegativeEnlistUserActivity : ";
    private TabLayout enlistTab;
    private ViewPager enlistVp;
    private List<Fragment> fragments = new ArrayList<>();
    private QuickFragmentAdapter<Fragment> fragmentAdapter;
    private String[] titles = new String[]{"待同意", "已同意"};
    private LinearLayout linearLayout;

    @Override
    protected void initView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_negative_enlist);
        fragments.add(new NegParToAgreeFragment());
        fragments.add(new NegParAgreedFragment());
        ((TextView) findViewById(R.id.common_title_text)).setText("已报名用户");
        fragmentAdapter = new QuickFragmentAdapter<>(getSupportFragmentManager(), fragments, titles);

        enlistTab = (TabLayout) findViewById(R.id.enlist_tab);
        enlistVp = (ViewPager) findViewById(R.id.enlist_vp);
        enlistVp.setAdapter(fragmentAdapter);
        enlistTab.setupWithViewPager(enlistVp);
        enlistVp.setOffscreenPageLimit(2);

        linearLayout = (LinearLayout) enlistTab.getChildAt(0);
        linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
        linearLayout.setDividerDrawable(ContextCompat.getDrawable(this, R.drawable.shape_vertical_divider_gray));
        linearLayout.setDividerPadding(ScreenUtil.dip2px(NegativeEnlistUserActivity.this, 15));
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void loadNetData() {

    }

    public static void startNegEnlist(Context context, String activityId) {
        Intent intent = new Intent(context, NegativeEnlistUserActivity.class);
        intent.putExtra("activity_id", activityId);
        context.startActivity(intent);
    }

    @Override
    protected void setListener() {
        findViewById(R.id.common_back).setOnClickListener(this);
        findViewById(R.id.common_home_back).setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.common_back:
                ActivityCollector.removeActivity(this);
                break;
            case R.id.common_home_back:
                startActivity(new Intent(NegativeEnlistUserActivity.this, MainActivity.class));
                break;
        }
    }
}
